module get_request(
	input clk,
	input rst,

	input [4:0] in_reqnew,
	input [4:0] out_requpnew,
	input [4:0] out_reqdownnew,
	

	
	input [4:0] keyL,

	
	input [3:0] out_keyup,
	input [4:0] out_keydown,
	
	output reg [4:0] in_req,

	output reg [4:0] out_requp,
	output reg [4:0] out_reqdown
);

initial
	begin
		in_req <= 5'b00000;
		out_requp <= 5'b00000;
		out_reqdown <= 5'b00000;
	end
	
	
//request inside the elevator

always@(negedge keyL[0] or negedge in_reqnew[0])
	begin
	if (keyL[0] == 0)
	in_req[0] <= 1'b1;
	if (in_reqnew[0] == 0)
	in_req[0] <= 1'b0;
	end
	
always@(negedge keyL[1] or negedge in_reqnew[1])
	begin
	if (keyL[1] == 0)
	in_req[1] <= 1'b1;
	if (in_reqnew[1] == 0)
	in_req[1] <= 1'b0;
	end
	
always@(negedge keyL[2] or negedge in_reqnew[2])
	begin
	if (keyL[2] == 0)
	in_req[2] <= 1'b1;
	if (in_reqnew[2] == 0)
	in_req[2] <= 1'b0;
	end

always@(negedge keyL[3] or negedge in_reqnew[3])
	begin
	if (keyL[3] == 0)
	in_req[3] <= 1'b1;
	if (in_reqnew[3] == 0)
	in_req[3] <= 1'b0;
	end

always@(negedge keyL[4] or negedge in_reqnew[4])
	begin
	if (keyL[4] == 0)
	in_req[4] <= 1'b1;
	if (in_reqnew[4] == 0)
	in_req[4] <= 1'b0;
	end
	


	
//requestup outside the elevator
always@(negedge out_keyup[0] or negedge out_requpnew[0] )
	begin
	if (out_keyup[0] == 0)
	out_requp[0]<=1'b1;
	if (out_requpnew[0] ==0)
	out_requp[0]<=1'b0;
	end
	
always@(negedge out_keyup[1] or negedge out_requpnew[1] )
	begin
	if (out_keyup[1] == 0)
	out_requp[1]<=1'b1;
	if (out_requpnew[1] == 0)
	out_requp[1]<=1'b0;
	end
	
always@(negedge out_keyup[2] or negedge out_requpnew[2] )
	begin
	if (out_keyup[2] == 0)
	out_requp[2]<=1'b1;
	if (out_requpnew[2] ==0)
	out_requp[2]<=1'b0;
	end

always@(negedge out_keyup[3] or negedge out_requpnew[3] )
	begin
	if (out_keyup[3] == 0)
	out_requp[3]<=1'b1;
	if (out_requpnew[3] ==0)
	out_requp[3]<=1'b0;
	end

	
	
//requestdown outside the elevator

	
always@(negedge out_keydown[1] or negedge out_reqdownnew[1])
	begin
	if (out_keydown[1]==0)
	out_reqdown[1]<=1'b1;
	if (out_reqdownnew[1]==0)
	out_reqdown[1]<=1'b0;
	end
	
always@(negedge out_keydown[2] or negedge out_reqdownnew[2])
	begin
	if (out_keydown[2]==0)
	out_reqdown[2]<=1'b1;
	if (out_reqdownnew[2]==0)
	out_reqdown[2]<=1'b0;
	end

always@(negedge out_keydown[3] or negedge out_reqdownnew[3])
	begin
	if (out_keydown[3]==0)
	out_reqdown[3]<=1'b1;
	if (out_reqdownnew[3]==0)
	out_reqdown[3]<=1'b0;
	end	

always@(negedge out_keydown[4] or negedge out_reqdownnew[4])
	begin
	if (out_keydown[4]==0)
	out_reqdown[4]<=1'b1;
	if (out_reqdownnew[4]==0)
	out_reqdown[4]<=1'b0;
	end



endmodule
